const axios = require('axios');
const { getWxAPIAccessToken } = require('./accesstoken');

async function sendSubscribeMessage (templateId, openId, page, data) {
    let res = await axios.post('https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' + await getWxAPIAccessToken(),
        {
            touser: openId,
            template_id: templateId,
            page: page,
            lang: 'zh_CN',
            data: data
        });
    return res.data;
}

module.exports = {
    sendSubscribeMessage
};
